<%--
* @version: 1.0
* @author: jinmingming
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" language="javascript" src="<%=path %>/mnHtml/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" language="javascript" src="<%=path %>/mnHtml/js/examglobal.js"></script>
<title>市外模拟交费信息查询</title>
</head>
<style type="text/css">
	  table tr{
		line-height: 50px;
	  }
    </style>
<body>
	<%
		if(session.getAttribute("queryuser")==null){
			request.getRequestDispatcher("./query.jsp").forward(request, response);
		}
	%>
<br/><br/><br/><br/>
	<table align="center" style="width: 300px;">
		<tr>
			<td colspan="2" align="center">市外模拟交费信息查询</td>
		</tr>
		<tr>
			<td>请选择模拟场次：</td>
			<td>
				<select id="examnum">
						<option selected="selected">布外模考</option>
						<!-- <option>深外三模</option> -->
				</select>
			</td>
		</tr>
		<tr>
			<td>请输入准考证号：</td>
			<td><input type="text" id="ticknum"></td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="button" value="查询" id="query">
			</td>
		</tr>
	</table>
	
	<table align="center" id="result" style="width: 400px;color: red;display: none;border: solid 1px;border-color: black;">
		<tr>
			<td colspan="2" align="center"><strong>查询结果</strong></td>
		</tr>
		<tr>
			<td>姓名：</td>
			<td id="rname">
			</td>
		</tr>
		<tr>
			<td>准考证号：</td>
			<td id="rticknum">
			</td>
		</tr>
		<tr>
			<td>是否在蓝天就读：</td>
			<td id="rissky">
			</td>
		</tr>
		<tr>
			<td>是否已领入场券：</td>
			<td>
				<strong id="rispayment"></strong>
			</td>
		</tr>
	</table>
</body>
<script type="text/javascript">
	$(function(){
		$("#ticknum").focus();
		
		$("#query").click(function(){
			query();
		});
		

		$("#pay").live("click",function(){
			update("是");
		});
		
		$("#nopay").live("click",function(){
			update("否");
		});
		
	});
		function query(){
			var examnum = $("#examnum").val();
			var ticknum = $("#ticknum").val();
			$.ajax({
				type:"POST",
				async:false,
				url:PATH + "/ExamServlet?action=ispayment&examnum="+encodeURI(examnum)+"&ticknum="+encodeURI(ticknum),
				success:function(data){
					if(data=="NoResult"){
						$("#result").hide();
						alert("您查询的信息不存在");
					}else{
						data = eval('(' + data + ')');
						$("#rname").html(data.sname+"<input type='text' value="+data.id+" id='rid' style='display: none;'/>");
						$("#rticknum").html(data.ticknum);
						$("#rissky").html(data.issky);
						
						if(data.ispayment=="是"){
							$("#rispayment").html(data.ispayment + "&nbsp;&nbsp;&nbsp;<input type='button' value='取消领入场券操作' id='nopay'>");
						}else{
							$("#rispayment").html(data.ispayment + "&nbsp;&nbsp;&nbsp;<input type='button' value='确认已领入场券 ' id='pay'>");
						}
						
						$("#result").show();
						//$("#ticknum").val("");
					}
					$("#ticknum").focus();
				}
			});
		}
	
		function update(ispayment){
			$.ajax({
				type:"POST",
				async:false,
				url:PATH + "/ExamServlet?action=updateIspayment&id="+encodeURI($("#rid").val())+"&ispayment="+encodeURI(ispayment),
				success:function(data){
					if(data=="true"){
						if(ispayment=="是"){
							$("#rispayment").html("是&nbsp;&nbsp;&nbsp;<input type='button' value='取消已领入场券' id='nopay'>");
							alert("取消已领入场券成功！");
						}else{
							$("#rispayment").html("否&nbsp;&nbsp;&nbsp;<input type='button' value='确认已领入场券' id='pay'>");
							alert("确认成功！");
						}
						
					}else{
						alert("操作失败！");
					}
				}
			});
		}
	

		
</script>
</html>